package net.zjitc.service.User.impl;

import net.zjitc.action.Utils.UUIDutils;
import net.zjitc.damain.User.User;
import net.zjitc.dao.User.UserDao;
import net.zjitc.service.User.UserService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by Administrator on 2017/3/10.
 */
@Service
@Transactional
public class UserServiceImpl implements UserService{
    @Resource
    private UserDao userDao;

    @Override
    public List<User> findAll() {
        return userDao.findAll();
    }

    @Override
    public User getById(Integer id) {
        return userDao.getById(id);
    }

    @Override
    public void Delete(User user) {
        userDao.Delete(user);
    }

    @Override
    public void save(User model) {
        model.setState(0);
        String code = UUIDutils.uuid();
        model.setCode(code);
        userDao.save(model);
    }

    @Override
    public User findByUsernamePassword(String username, String password) {
        return userDao.findByUsernamePassword(username,password);
    }
}
